import 'package:flutter/material.dart';
class Test19 extends StatefulWidget{
    _TestState createState() => _TestState();
}

class _TestState extends State<Test19> {

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: AppBar(
            title: Text("ClipPath裁剪"),
            centerTitle: true,
        ),
        body: Container(
            child: Column(
                children: <Widget>[
                    ClipPath(
                        child: Image.network(
                            "https://img.zcool.cn/community/0372d195ac1cd55a8012062e3b16810.jpg",
                        ),
                        clipper: BottomWaveClipper(),
                    ),
                    Divider(color: Colors.red),
                    Container(
                        child: Text("5555555"),
                    )
                ],
            )
        ),
        
    );
  }
}


class BottomWaveClipper extends CustomClipper<Path>{

    @override
    Path getClip(Size size) {
        var path = Path();

        // path.lineTo(0.0, size.height-20);

        // var firstControlPoint = Offset(size.width/4, size.height);
        // var firstEndPoint = Offset(size.width/2.25, size.height-30);
        // path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy, firstEndPoint.dx, firstEndPoint.dy);

        // var secondControlPoint = Offset(size.width - (size.width / 3.25), size.height - 65);
        // var secondEndPoint = Offset(size.width, size.height - 40);
        // path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
        //     secondEndPoint.dx, secondEndPoint.dy);

        // path.lineTo(size.width, size.height - 40);
        // path.lineTo(size.width, 0.0);

        // path.moveTo(0, 0);//起始点
        // path.lineTo(100.0, 50.0);
        // path.lineTo(100.0, 100.0);

        // print(size.height);     //图片放到手机里面的高度 257
        // print(size.width);      //图片放到手机里面的宽度 411
        path.lineTo(0.0, size.height);
        
        
        path.quadraticBezierTo(size.width/4, size.height/4*3,size.width/2, size.height/8*7);
        path.quadraticBezierTo(size.width/4*3,size.height,size.width, size.height/8*7);

        path.lineTo(size.width, 0.0);

        path.close();
        return path;
    }

    @override
    bool shouldReclip(CustomClipper<Path> oldClipper) {
        return false;
    }
}
